var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(t, e) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(t, e) {
        t.__proto__ = e;
    } || function(t, e) {
        for (var n in e) e.hasOwnProperty(n) && (t[n] = e[n]);
    })(t, e);
}, function(t, e) {
    function n() {
        this.constructor = t;
    }
    o(t, e), t.prototype = null === e ? Object.create(e) : (n.prototype = e.prototype, 
    new n());
}), a = this && this.__decorate || function(t, e, n, o) {
    var a, i = arguments.length, c = i < 3 ? e : null === o ? o = Object.getOwnPropertyDescriptor(e, n) : o;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) c = Reflect.decorate(t, e, n, o); else for (var l = t.length - 1; 0 <= l; l--) (a = t[l]) && (c = (i < 3 ? a(c) : 3 < i ? a(e, n, c) : a(e, n)) || c);
    return 3 < i && c && Object.defineProperty(e, n, c), c;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("Global"), s = e("BaseView"), c = e("AudioManager"), l = e("MyButton"), d = e("GameConfig"), u = e("ActivityManager"), p = e("EggsManager"), h = e("GameData"), f = e("DataManager"), g = e("WebManager"), m = e("UIManager"), y = e("DrawManager"), v = cc._decorator, w = v.ccclass, b = v.property, P = function(e) {
    function t() {
        var t = null !== e && e.apply(this, arguments) || this;
        return t.editBox = null, t.myButton = null, t.tipsLabel = null, t;
    }
    return i(t, e), t.prototype.onEnable = function() {
        cc.systemEvent.on(this.text, this.callback, this);
    }, t.prototype.onDisable = function() {
        cc.systemEvent.off(this.text, this.callback, this);
    }, t.prototype.onClickOpen = function() {
        c.default.getInstance().playAudio("按钮2"), g.default.getInstance().sentLog("点击输入兑换码开启按键"), 
        this.showPnl();
    }, t.prototype.onClickClose = function() {
        c.default.getInstance().playAudio("按钮2"), g.default.getInstance().sentLog("点击输入兑换码关闭按键"), 
        this.hidePnl();
    }, t.prototype.onClick = function(l) {
        var t, e, s = this;
        if (c.default.getInstance().playAudio("按钮2"), GA.Info.underCheck && d.GC.isDebug) return m.default.getInstance().loadPopPnl("draw_reward", y.default.getInstance().doDraw()), 
        this.hidePnl(), void (-1 == p.default.getInstance().checkEggPerson(23) && u.ActivityManager.getInstance().checkActivity(u.ActivityType.THIRD) && (0 == r.G.newActivityCodeCount && setTimeout(function() {
            r.G.newActivityCodeCount = 0;
        }, 36e5), r.G.newActivityCodeCount++, 3 == r.G.newActivityCodeCount && -1 == p.default.getInstance().checkEggPerson(23) && (p.default.getInstance().updateEggPerson(23), 
        h.GD.personIdx = -24, h.GD.eggsHintState = 1, f.default.getInstance().save(), g.default.getInstance().sentLog("获得皮肤彩蛋id:23"), 
        r.G.queue.push({
            name: "egg_reward",
            type: 2,
            data: {
                type: r.RewardType.SKIN,
                idx: 23
            }
        }))));
        g.default.getInstance().sentLog("点击输入兑换码兑换按键"), this.editBox.textLabel.string ? g.default.getInstance().checkGiftCode({
            giftCode: this.editBox.textLabel.string,
            success: function(t) {
                var e, n, o, a, i;
                cc.log("checkGiftCode", t), isNaN(t.data.code) ? GA.isPlatform(GA.Platform.Kwaigame) ? m.default.getInstance().showToast({
                    str: "兑换码错误，请快手搜索“我就要吃鸡”获得",
                    delay: 2
                }) : GA.isPlatform(GA.Platform.ByteDance) ? null === (o = null === (i = GA.PA) || void 0 === i ? void 0 : i.showToast) || void 0 === o || o.call(i, {
                    title: "兑换码错误，请抖音搜索“我就要吃鸡”获得",
                    icon: "none"
                }) : null === (i = null === (a = GA.PA) || void 0 === a ? void 0 : a.showToast) || void 0 === i || i.call(a, {
                    title: "兑换码错误，请微信搜索”卡日曲游戏“公众号获得",
                    icon: "none"
                }) : 0 == t.data.code ? s.myButton.onClick(l) : 20 == t.data.code ? (cc.log("已兑换"), 
                GA.isPlatform(GA.Platform.Kwaigame) ? m.default.getInstance().showToast({
                    str: "该兑换码已兑换"
                }) : null === (t = null === (a = GA.PA) || void 0 === a ? void 0 : a.showToast) || void 0 === t || t.call(a, {
                    title: "该兑换码已兑换",
                    icon: "none"
                })) : (cc.log("兑换失败"), GA.isPlatform(GA.Platform.Kwaigame) ? m.default.getInstance().showToast({
                    str: "兑换码错误，请快手搜索“我就要吃鸡”获得",
                    delay: 2
                }) : GA.isPlatform(GA.Platform.ByteDance) ? null === (e = null === (n = GA.PA) || void 0 === n ? void 0 : n.showToast) || void 0 === e || e.call(n, {
                    title: "兑换码错误，请抖音搜索“我就要吃鸡”获得",
                    icon: "none"
                }) : null === (n = null === (e = GA.PA) || void 0 === e ? void 0 : e.showToast) || void 0 === n || n.call(e, {
                    title: "兑换码错误，请微信搜索”卡日曲游戏“公众号获得",
                    icon: "none"
                }));
            }
        }) : GA.isPlatform(GA.Platform.Kwaigame) ? m.default.getInstance().showToast({
            str: "输入内容不能为空"
        }) : null === (e = null === (t = GA.PA) || void 0 === t ? void 0 : t.showToast) || void 0 === e || e.call(t, {
            title: "输入内容不能为空",
            icon: "none"
        });
    }, t.prototype.callback = function() {
        var e = this;
        g.default.getInstance().giftCode({
            giftCode: this.editBox.textLabel.string,
            success: function(t) {
                cc.log("giftCode", t), isNaN(t.data.code) || 0 == t.data.code && (cc.log("兑换成功"), 
                m.default.getInstance().loadPopPnl("draw_reward", y.default.getInstance().doDraw()), 
                f.default.getInstance().save(), e.hidePnl(), -1 == p.default.getInstance().checkEggPerson(23) && u.ActivityManager.getInstance().checkActivity(u.ActivityType.THIRD) && (0 == r.G.newActivityCodeCount && setTimeout(function() {
                    r.G.newActivityCodeCount = 0;
                }, 36e5), r.G.newActivityCodeCount++, 3 == r.G.newActivityCodeCount && -1 == p.default.getInstance().checkEggPerson(23) && (p.default.getInstance().updateEggPerson(23), 
                h.GD.personIdx = -24, h.GD.eggsHintState = 1, f.default.getInstance().save(), g.default.getInstance().sentLog("获得皮肤彩蛋id:23"), 
                r.G.queue.push({
                    name: "egg_reward",
                    type: 2,
                    data: {
                        type: r.RewardType.SKIN,
                        idx: 23
                    }
                }))));
            }
        });
    }, t.prototype.start = function() {
        GA.isPlatform(GA.Platform.Kwaigame) ? this.tipsLabel.string = "快手中，搜索“我就要吃鸡”，可找到大量兑换码！" : GA.isPlatform(GA.Platform.ByteDance) ? this.tipsLabel.string = "抖音中，搜索“我就要吃鸡”，可找到大量兑换码！" : this.tipsLabel.string = "微信中，搜索”卡日曲游戏“公众号，可找到大量兑换码！";
    }, a([ b(cc.EditBox) ], t.prototype, "editBox", void 0), a([ b(l.default) ], t.prototype, "myButton", void 0), 
    a([ b(cc.Label) ], t.prototype, "tipsLabel", void 0), a([ w ], t);
}(s.default);

n.default = P;